package adapter;

import java.util.ArrayList;

import com.qzhy.female.R;

import Constant.Constance;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import model.Category;
import model.Image;
import utils.UILUtils;

public class post_img_adapter extends BaseAdapter{

	private Context context;
	private ArrayList<Category> dateCircleInfo;
	private ArrayList<Image> mArticleImg;
	private ViewHold viewHold;

	public post_img_adapter(Context context) {
		this.context = context;
		
	}
	public post_img_adapter(Context context, ArrayList<Image> mArticleImg) {
		this.context = context;
		// TODO Auto-generated constructor stub
		this.mArticleImg = mArticleImg;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mArticleImg.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=View.inflate(context, R.layout.item_post_detail_img, null);
			viewHold = new ViewHold();
			viewHold.ImgArticle=(ImageView) convertView.findViewById(R.id.img_article);
			convertView.setTag(viewHold);
		}else {
			viewHold = (ViewHold) convertView.getTag();
		}	
		 if(mArticleImg.size()>0){
			 if(mArticleImg.get(position).getUrl().startsWith("http")){
				 UILUtils.displayImageNoAnim(mArticleImg.get(position).getUrl(), viewHold.ImgArticle);
			 }else {
				 UILUtils.displayImageNoAnim(Constance.URL.IMG_BASE+"/"+mArticleImg.get(position).getUrl(), viewHold.ImgArticle);
			}
		 }
		return convertView;
	}
	
	class ViewHold{
		ImageView ImgArticle;
	}

}
